package com.qysoft.dtkj.dtkj_gl.actions.kjcj;

import java.util.HashMap;
import java.util.List;

import com.jfinal.aop.Before;
import com.jfinal.plugin.ehcache.CacheKit;
import com.qysoft.dtkj.dtkj_gl.services.common.CommonService;
import com.qysoft.dtkj.dtkj_gl.services.kjcj.KJCJService;
import com.qysoft.rapid.actions.JsonResultInterceptor;
import com.qysoft.rapid.actions.RapidAction;
import com.qysoft.rapid.core.RapidDbConnTx;

/**
 * 跨界采集action
 * @author liugong
 *
 */
public class KJCJAction extends RapidAction{

	public void ssgsxxIndex() throws Exception{
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> qyxxList = CacheKit.get("dm", "ssqyxx");
		if (qyxxList==null) {
			qyxxList = CommonService.queryQyxx("1");
			CacheKit.put("dm", "ssqyxx", qyxxList);
		}
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> capList = CacheKit.get("dm", "capListA");
		if (capList==null) {
			capList = CommonService.queryCapInfo("A");
			CacheKit.put("dm", "capListA", capList);
		}
		setAttr("qyxxList", qyxxList);
		setAttr("capList", capList);
		renderJsp("/WEB-INF/pages/kjcj/ssgsxx.jsp");
	}
	
	public void zdsyqyIndex() throws Exception{
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> qyxxList = CacheKit.get("dm", "zdsyqy");
		if (qyxxList==null) {
			qyxxList = CommonService.queryQyxx("");
			CacheKit.put("dm", "zdsyqy", qyxxList);
		}
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> capList = CacheKit.get("dm", "capListB");
		if (capList==null) {
			capList = CommonService.queryCapInfo("B");
			CacheKit.put("dm", "capListB", capList);
		}
		setAttr("qyxxList", qyxxList);
		setAttr("capList", capList);
		renderJsp("/WEB-INF/pages/kjcj/zdsyqy.jsp");
	}	
	
	public void mtjyxxIndex() throws Exception{
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> qyxxList = CacheKit.get("dm", "zdsyqy");
		if (qyxxList==null) {
			qyxxList = CommonService.queryQyxx("");
			CacheKit.put("dm", "zdsyqy", qyxxList);
		}
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> capList = CacheKit.get("dm", "capListC");
		if (capList==null) {
			capList = CommonService.queryCapInfo("C");
			CacheKit.put("dm", "capListC", capList);
		}
		setAttr("qyxxList", qyxxList);
		setAttr("capList", capList);
		renderJsp("/WEB-INF/pages/kjcj/mtjyxx.jsp");
	}		
	
	public void dljyxxIndex() throws Exception{
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> qyxxList = CacheKit.get("dm", "zdsyqy");
		if (qyxxList==null) {
			qyxxList = CommonService.queryQyxx("");
			CacheKit.put("dm", "zdsyqy", qyxxList);
		}
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> capList = CacheKit.get("dm", "capListD");
		if (capList==null) {
			capList = CommonService.queryCapInfo("D");
			CacheKit.put("dm", "capListD", capList);
		}
		setAttr("qyxxList", qyxxList);
		setAttr("capList", capList);
		renderJsp("/WEB-INF/pages/kjcj/dljyxx.jsp");
	}		
	
	public void zdgctzIndex() throws Exception{
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> qyxxList = CacheKit.get("dm", "zdsyqy");
		if (qyxxList==null) {
			qyxxList = CommonService.queryQyxx("");
			CacheKit.put("dm", "zdsyqy", qyxxList);
		}
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> capList = CacheKit.get("dm", "capListE");
		if (capList==null) {
			capList = CommonService.queryCapInfo("E");
			CacheKit.put("dm", "capListE", capList);
		}
		setAttr("qyxxList", qyxxList);
		setAttr("capList", capList);
		renderJsp("/WEB-INF/pages/kjcj/zdgctz.jsp");
	}		
	
	public void gqbgxxIndex() throws Exception{
		//获取所有上市企业信息（缓存）
		List<HashMap<String, Object>> qyxxList = CacheKit.get("dm", "zdsyqy");
		if (qyxxList==null) {
			qyxxList = CommonService.queryQyxx("");
			CacheKit.put("dm", "zdsyqy", qyxxList);
		}
		setAttr("qyxxList", qyxxList);
		renderJsp("/WEB-INF/pages/kjcj/gqbgxx.jsp");
	}	
	
	
	@Before(value={JsonResultInterceptor.class,RapidDbConnTx.class})	
	public void addFav() throws Exception{
		String infoid = getPara("infoid");
		String userid = getCurrentRyxx().getId();
		KJCJService.addFav(userid, infoid);
	}
	
	
	@Before(value={JsonResultInterceptor.class,RapidDbConnTx.class})		
	public void delFav() throws Exception{
		String infoid = getPara("infoid");
		String userid = getCurrentRyxx().getId();
		KJCJService.delFav(userid, infoid);
	}
	
	@Before(value={JsonResultInterceptor.class,RapidDbConnTx.class})		
	public void push() throws Exception{
		String userids = getPara("userids");
		String infoid = getPara("infoid");
		String fromuserid = getCurrentRyxx().getId();
		KJCJService.push(userids, infoid, fromuserid); 
	}
	
}
